import edge_tts
import asyncio
import uuid

async def textAudio(text="",voice="",rate="",volume=""):
    substr = text[:1]
    new_filename =substr+'_'+ uuid.uuid4().hex + '.' + 'mp3'  # 生成随机文件名
    output = 'files/' + new_filename
    tts = edge_tts.Communicate(text=text,voice=voice,rate=rate,volume=volume)
    await tts.save(output)
    return new_filename
if __name__ == '__main__':
    asyncio.run(textAudio('你好啊',voice='xiaoyan',rate='100',volume='100'))
